package git.bankview.wl.report;

import java.util.*;
import java.sql.*;
import java.io.*;

import laya.semi.process.*;
import git.bankview.sl.report.ReportCommon;
import git.bankview.sl.report.SchdUtil;

import git.bankview.sl.db.*;

import org.apache.log4j.Logger;

public class SchdEntryGenerator
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(SchdEntryGenerator.class);
	
	private static final String SQL_UPDATER = 
		"update dqschdentry set transid = ?, schddate = ?, schdtype = ?, schdexport = ?, schdstatus = ? where schdid = ?";
	
	/**
	 * param[0]: schdexport fieldname
	 *
	 */
	public void execute(IProcessContext oCtx)
		throws Exception
	{
		String[] vFieldName = oCtx.getActivityParameter().split(":");
		String[] vExport = (String[])oCtx.getField(vFieldName[0]);
		String[] vSchdtype = (String[])oCtx.getField(vFieldName[1]);
		
		Connection oConn = DBConnectionFactory.getCoreConnection();
		try
		{
			int nSchdId = 
				SchdUtil.addSchdEntry((String)oCtx.getField("transid"), new java.util.Date()
					, Integer.parseInt(vSchdtype[0]), vExport[0]
					, oConn);
			oCtx.setField("schdid", new Integer(nSchdId));
		}
		finally
		{
			oConn.close();
		}
	}
}
